import React, { Component } from 'react'
import TitleBack from "../../components/TitleBack/TitleBack"
import { reqgetcate, reqgetgoods } from '../../http/api'
import "./Cate.less"



export default class Cate extends Component {
    constructor(){
        super()
        this.state={
            cate:[]
        }
    }
    async componentDidMount() {
        let res1 = await reqgetcate()
        if (res1.data.code === 200) {
            this.setState({
                cate:res1.data.list
            })
        }
    }
    change(id){
        reqgetgoods({pid:id}).then(res=>{
            console.log(11111111111111111111);
        })
    }
    render() {
        let {cate}=this.state
        return (
            <div className="cate">
                <TitleBack title={"商品分类"}></TitleBack>
                <ul className="catenav">
                    {
                        cate.map(item=>{
                            return <li key={item.id} onClick={()=>this.change(item.pid)}>{item.catename}</li>
                        })
                    }
                </ul>
            </div>
        )
    }
}
